String clazzTpl({package}) => """
import 'package:xanno/xanno.dart';
import 'package:flutter/material.dart';
import 'package:$package/debug/slice/actions.dart';
import 'package:$package/l10n/generated/l10n.dart';
import 'package:$package/widget/theme_builder.dart';
import 'package:$package/mixin/base_widget_mixin.dart';
import 'package:$package/widget/base_store_container.dart';

@GRoute(url: '/', title: 'main')
class MainPage extends StatefulWidget {
  final String title;

  const MainPage({Key? key, required this.title}) : super(key: key);

  @override
  State<MainPage> createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> with BaseStatefulMixin {
  int counter = 0;

  @override
  void initState() {
    /// 模拟错误，产生错误日志，进入debug页面查看
    /// emulate error, generate error log, enter debug page to view
    Future.error('Custom error', StackTrace.fromString('StackTrace error'));
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return ThemeBuilder(
      builder: (context, theme) {
        return Scaffold(
          backgroundColor: theme.body,
          appBar: AppBar(
            systemOverlayStyle: theme.systemOverlayStyleReverse,
            backgroundColor: theme.body,
            title: Text(
              widget.title,
              style: TextStyle(
                fontSize: 30,
                fontWeight: FontWeight.bold,
                color: theme.title,
              ),
            ),
            actions: [
              IconButton(
                onPressed: () {
                  /// change theme
                  context.dispatch(ThemeActions.updateTheme(theme.type =
                      theme.type == ThemeType.light
                          ? ThemeType.dark
                          : ThemeType.light));
                },
                icon: Icon(Icons.wb_incandescent, color: theme.title, size: 30),
              )
            ],
          ),
          body: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Align(
                child: Text(
                  '\${S.of(context).xanno} 👍 \$counter',
                  style: TextStyle(
                    fontSize: 30,
                    fontWeight: FontWeight.bold,
                    color: theme.title,
                  ),
                ),
              ),
              TextButton(
                onPressed: () =>
                    Navigator.pushNamed(context, RouteConstant.AppDebugPage),
                style: ButtonStyle(
                  backgroundColor:
                      MaterialStateProperty.all(theme.title.withOpacity(0.2)),
                  overlayColor:
                      MaterialStateProperty.all(theme.title.withOpacity(0.2)),
                  padding: MaterialStateProperty.all(const EdgeInsets.all(10)),
                  shape: MaterialStateProperty.all(const StadiumBorder()),
                ),
                child: Text(
                  S.of(context).desc('debug'),
                  style: TextStyle(color: theme.title),
                ),
              ),
            ],
          ),
          floatingActionButton: FloatingActionButton(
            onPressed: () {
              /// counter++
              setState(() {
                counter++;
              });
            },
            backgroundColor: theme.title,
            child: Icon(Icons.add, color: theme.body),
          ),
        );
      },
    );
  }
}
""";
